package org.cjstudio.messageboard.model;

import java.util.Date;

public class Message {
	
	public static final String kind = "Message";
	public static final String pn_name = "name";
	public static final String pn_phoneNumber = "phoneNumber";
	public static final String pn_content = "content";
	public static final String pn_date = "date";
	
	/*
	public static final Class pt_name = String.class;
	public static final Class pt_phoneNumber = String.class;
	public static final Class pt_content = String.class;
	public static final Class pt_date = Date.class;
	*/
	
	private String name;
	private String phoneNumber;
	private String content;
	private Date date;
	
	public Message(String name, String phoneNumber, String content) {
		this.name = name;
		this.phoneNumber = phoneNumber;
		this.content = content;
		this.date = new Date();
	}
	
	public Message(String name, String phoneNumber, String content, Date date) {
		this.name = name;
		this.phoneNumber = phoneNumber;
		this.content = content;
		this.date = date;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@Override
	public String toString() {
		return "Message [name=" + name + ", phoneNumber=" + phoneNumber
				+ ", content=" + content + ", date=" + date + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((content == null) ? 0 : content.hashCode());
		result = prime * result + ((date == null) ? 0 : date.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Message other = (Message) obj;
		if (content == null) {
			if (other.content != null)
				return false;
		} else if (!content.equals(other.content))
			return false;
		if (date == null) {
			if (other.date != null)
				return false;
		} else if (!date.equals(other.date))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (phoneNumber == null) {
			if (other.phoneNumber != null)
				return false;
		} else if (!phoneNumber.equals(other.phoneNumber))
			return false;
		return true;
	}
}
